package com.tz.crm.entity;

import javax.persistence.*;
import java.util.Date;

/**
 * 付款计划
 */
@Entity
@Table(name = "tbl_payment")
public class Payment extends BaseEntity {

    private static final long serialVersionUID = 4070590554145379906L;

    /**
     * 付款方式枚举
     */
    public enum PayName {
        firstPay,
        leftPay,
        lastPay,
        allPay
    }

    private PayName payName;//付款方式
    private double amount;//金额
    private String remark;//备注
    private Date dueDate;//计划到款日期
    private Date payOffDate;//实际到款日期
    private User signUser;//到款确认人
    private boolean paid;//已付款标记
    private Contract contract; //属于哪个合同

    /**
     * 空参构造
     */
    public Payment() {
    }

    @Enumerated(EnumType.STRING)
    public PayName getPayName() {
        return payName;
    }

    public void setPayName(PayName payName) {
        this.payName = payName;
    }

    public double getAmount() {
        return amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Temporal(TemporalType.DATE)
    public Date getDueDate() {
        return dueDate;
    }

    public void setDueDate(Date dueDate) {
        this.dueDate = dueDate;
    }

    @Temporal(TemporalType.DATE)
    public Date getPayOffDate() {
        return payOffDate;
    }

    public void setPayOffDate(Date payOffDate) {
        this.payOffDate = payOffDate;
    }

    @ManyToOne
    @JoinColumn(name = "user_id")
    public User getSignUser() {
        return signUser;
    }

    public void setSignUser(User signUser) {
        this.signUser = signUser;
    }

    @ManyToOne
    @JoinColumn(name = "contract_id")
    public Contract getContract() {
        return contract;
    }

    public void setContract(Contract contract) {
        this.contract = contract;
    }

    public boolean isPaid() {
        return paid;
    }

    public void setPaid(boolean paid) {
        this.paid = paid;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("Payment{");
        sb.append("payName=").append(payName);
        sb.append(", signUser=").append(signUser);
        sb.append(", contract=").append(contract);
        sb.append('}');
        return sb.toString();
    }
}
